﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tradex.Connectivity {

    /// <summary>
    /// The ConnectionStatusCode tracks the different stati a connection can have in Tradex.
    /// </summary>
    public enum ConnectionStatusCode {

        /// <summary>
        /// The wrapper is starting. This is a status that should not come from the wrapper. It identifies server side
        /// that a wrapper has been initiated (the process spawned) but not reported back.
        /// </summary>
        Starting,

        /// <summary>
        /// The connector wrapper has started. This is the initial state when a wrapper starts that it reports.
        /// At this status, the wrapper is "empty" (i.e. has no connector code actually loaded), and thus also not
        /// connected.
        /// </summary>
        Started,

        /// <summary>
        /// The connector is disconnected. It has, though, a connector loaded. This status is either an interim state
        /// from Started to Connected, or a stable state when a connector is asked to disconnect.
        /// </summary>
        Disconnected,

        /// <summary>
        /// The connector is in the process of connecting. This is an interim stage. Depending on the number
        /// of connections, the connector will move from here to "PartiallyConneted" or directly to "Connected".
        /// </summary>
        Connecting,

        /// <summary>
        /// The connector is partially connected. Some functions may not work. It will try to
        /// cure this situation. This reduced mode of operation may be an error condition (remote server down),
        /// but can also appear as part or normal maintenance or as natural part during connect/disconnect
        /// cycles.
        /// </summary>
        PartiallyConnected,

        /// <summary>
        /// The connector is fully connected nad operational.
        /// </summary>
        Connected,

        /// <summary>
        /// The connector is in the process of disconnecting.
        /// </summary>
        Disconnecting,

        /// <summary>
        /// The connector is disconnected and this was on administrative action from the other end - either by disabling
        /// an account, or by a failure during the login process.
        /// </summary>
        ForceDisconnect,

        /// <summary>
        /// An unexpected internal error has happened. The wrapper will NOT react to ANY further commands and will
        /// execute a shutdown (i.e. for new commands, a new wrapper must be started).
        /// This status should not be used for any "expected" errors (bad password, bad instrument etc.) but be a last
        /// resort for "something happened that should not have happened, technically, please send a dump to service".
        /// This status is reportes as error in the Tradex event log.
        /// </summary>
        Error,

        /// <summary>
        /// The connector is asked to stop. If it does not stop within a specific time, the connector will switch to the Error
        /// state.
        /// </summary>
        Stopping,

        /// <summary>
        /// The connector has stoppped, the process is being or has been discarded.
        /// </summary>
        Stopped,

        /// <summary>
        /// The connection has been deleted. As such it can be removed from all lists that show it.
        /// </summary>
        Deleted

    }

}
